package com.bidevalution.controller.util;

import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;

import com.bidevalution.support.util.LogUtil;

public class RequestUtil {
	private static ThreadLocal<Map<String, String>> threadLocal = new ThreadLocal<Map<String, String>>();
	private static LogUtil logUtil = LogUtil.getLogManager(RequestUtil.class);
	public static void setRequest(HttpServletRequest request) {
		Map<String, String> reqeustHeaderMap = new HashMap<String, String>();
		Enumeration<String> enumeration = request.getHeaderNames();
		String key = "";
		while (enumeration.hasMoreElements()) {
			key = enumeration.nextElement();
			reqeustHeaderMap.put(key, request.getHeader(key));
		}
		threadLocal.set(reqeustHeaderMap);
	}

	public static String getHeader(String key) {
		String headerValue = threadLocal.get().get(key.toLowerCase());
		logUtil.info("guid:>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"+headerValue);
		return headerValue;
	}
}
